/*******************************************************************************
 * Copyright (c) 2011 squid.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     squid - initial API and implementation
 ******************************************************************************/
package com.google.code.cubeirc.config;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;

import lombok.Data;

@Data
public class EditorSettings {
	private String name;
	private String fontname;
	private int fontsize;
	private String background;
	private String foreground;

	public EditorSettings(String name, String fontname, int fontsize, String background, String foreground)
	{
		super();
		this.name = name;
		this.fontname = fontname;
		this.fontsize = fontsize;
		this.background = background;
		this.foreground = foreground;
	}
	
	public Color getColorBackground()
	{
		return ConvertToColor(getBackground());
	}
	
	public Color getColorForeground()
	{
		return ConvertToColor(getForeground());
	}
	
	public Color ConvertToColor(String value)
	{
		String s_value = "";
		Color cl;
		//RGB {0, 0, 0}
		s_value = value.replace("RGB {", "").replace("}", "");
		String[] arr = s_value.split(",");
		cl = new Color(Display.getCurrent(),Integer.parseInt(arr[0].trim()), Integer.parseInt(arr[1].trim()), Integer.parseInt(arr[2].trim()) );
		return cl;
	}
	
	



}
